﻿using MySchool;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace dierci
{
    public partial class Form2 : Form
    {
        DBHelper db = new DBHelper();
        DataSet set = new DataSet();
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            db.OpenConnection();
            string sql = "select StationName,InputName,StartDate,EndDate,PM,[Level] from AirQualityInfoo inner join StationID on AirQualityInfoo.StationID=StationID.StationID";
            SqlDataAdapter adapter = new SqlDataAdapter(sql,db.Connection);
            adapter.Fill(set, "AirQualityInfoo");
            this.dataGridView1.DataSource = set.Tables["AirQualityInfoo"];
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            set.Tables["AirQualityInfoo"].Clear();
            db.OpenConnection();
            string sql = "select StationName,InputName,StartDate,EndDate,PM,[Level] from AirQualityInfoo inner join StationID on AirQualityInfoo.StationID=StationID.StationID where InputName =N'" + this.textBox1.Text+"'";
            SqlDataAdapter adapter = new SqlDataAdapter(sql,db.Connection);
            adapter.Fill(set, "AirQualityInfoo");
            this.dataGridView1.DataSource = set.Tables["AirQualityInfoo"];
            db.CloseConnection();
        }
    }
}
